/*
 * @Author: your name
 * @Date: 2021-10-04 17:46:10
 * @LastEditTime: 2021-10-04 18:03:04
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\1.2排序\P1177\3main.cpp
 */
#include <iostream>
#include <stack>
using namespace std;

// #define MAX_LENGTH 1000000010
#define MAX_LENGTH 100
 
//划分算法
int Partition( int a[], int low, int high )
{
	//假设每次都以第一个元素作为枢轴值，进行一趟划分：
	int pivot = a[low];
	 
	while( low<high )
	{
		while( low<high && a[high]>=pivot )
		--high;
		a[low] = a[high];  //停下来做交换 
		while( low<high && a[low]<=pivot )
		++low;
		a[high] = a[low];  //停下来做交换 
	}
	
	a[low] = pivot;  //pivot的最终落点 
	return low;
}
 
//非递归快排
void QuickSort(int a[], int left, int right)
{
	//手动利用栈来存储每次分块快排的起始点
	//栈非空时循环获取中轴入栈
	stack<int> s;
	if( left<right )
	{
		int boundary = Partition(a,left,right);

		if( boundary+1<right ) //确保右分区存在 
		{
			s.push(boundary+1);
			s.push(right);
		}
		
		if( boundary-1>left ) //确保左分区存在 
		{
			//将左分区端点入栈 
			s.push(left);
			s.push(boundary-1);
		}

		
		while( !s.empty() )
		{
			//得到某分区的左右边界 
			int r = s.top();
			s.pop();  
			int l = s.top();
			s.pop();
			
			boundary = Partition(a,l,r);
			if( boundary-1>l ) //确保左分区存在 
		    { 
			    //将左分区端点入栈 
		    	s.push(l);
		    	s.push(boundary-1);
	    	}
		    if( boundary+1<r ) //确保右分区存在 
	     	{
	 	    	s.push(boundary+1);
	    		s.push(r);
	    	}
		}
	}
}
 
int main()
{
	int a[MAX_LENGTH];
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	QuickSort(a,0,n-1);
	
	//输出，检验结果 
	for( int i=0; i<n; ++i )
	{
		cout << a[i] << " ";
	}
}